package com.nine.service.impl;

import com.nine.dao.DeptDao;
import com.nine.entity.Dept;
import com.nine.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author ：Fmc
 * @date ：Created in 2022/6/23 17:38
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptDao deptDao;
    /**
     * @create by: Fmc
     * @description: 查找全部部门（包含 模糊查询、排序）
     * @create time: 2022/6/27 16:48
     * @return: List<Dept>
     */
    @Override
    public List<Dept> selectAllDept(Map map) {
        return deptDao.selectAllDept(map);
    }
    /**
     * @create by: Fmc
     * @description: 添加新的部门信息
     * @create time: 2022/6/27 16:48
     * @return: int
     */
    @Override
    public int addDept(Map map) {
        return deptDao.addDept(map);
    }
    /**
     * @create by: Fmc
     * @description: 删除部门
     * @create time: 2022/6/27 16:49
     * @return: int
     */
    @Override
    public int deleteDept(String[] deptids) {
        return deptDao.deleteDept(deptids);
    }
    /**
     * @create by: Fmc
     * @description: 更改部门信息
     * @create time: 2022/6/27 16:49
     * @return: int
     */
    @Override
    public int updateDept(Dept dept) {
        return deptDao.updateDept(dept);
    }
    /**
     * @create by: Fmc
     * @description: 校验添加和删除的时候，部门名称是否重复
     * @create time: 2022/6/27 16:49
     * @return: boolean
     */
    @Override
    public boolean findDept(Dept dept) {
        List<Dept> deptList = deptDao.findDept(dept);
        if (deptList != null &&deptList.size() > 0){
            return false;
        }
        return true;
    }
    /**
     * @create by: Fmc
     * @description: 修改个人信息时，通过回显的部门名称查找部门id
     * @create time: 2022/6/29 18:17
     * @return: int
     */
    @Override
    public int selectDeptIdByDeptName(String deptName){
        return deptDao.selectDeptIdByDeptName(deptName);
    }
}
